﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace Lg.Core.Encryption
{
    public class SHA
    {
        #region【SHA1加密】
        /// <summary>
        /// SHA1加密
        /// </summary>
        /// <param name="str">待加密字符串</param>
        /// <returns>加密后字符串</returns>
        public static string ForSHA1(string str)
        {
            using (SHA1 sha1 = SHA1.Create())
            {
                return BitConverter.ToString(sha1.ComputeHash(Encoding.UTF8.GetBytes(str)));
            }
        }
        #endregion
        
        public static string ForSHA256(string str)
        {
            using (SHA256 sha = SHA256.Create())
            {
                return BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(str)));
            }
        }
        public static string ForSHA384(string str)
        {
            using (SHA384 sha = SHA384.Create())
            {
                return BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(str)));
            }
        }
        public static string ForSHA512(string str)
        {
            using (SHA512 sha = SHA512.Create())
            {
                return BitConverter.ToString(sha.ComputeHash(Encoding.UTF8.GetBytes(str)));
            }
        }

    }
}
